using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;


namespace DBRandomGenerator
{
    public partial class RDGenTableList : Form
    {
        public RDGenTableList()
        {
            InitializeComponent();
        }
        /*Load the tables in the combo box*/
        private void RDGenTableList_Load(object sender, EventArgs e)
        {
            txtNoOfRows.Text = "0";
            DCM RDGenDCM = new DCM();
            DataTable TableList = new DataTable();
            TableList = RDGenDCM.GetTableList();
            cbTableList.DisplayMember = "Table_Name";
            cbTableList.DataSource = TableList.DefaultView;
        }

        /* Get the meta data for the table selected and display the contents in a grid*/
        /* Generate the required number of insert statements for the selected table */
        private void cmdGenerate_Click(object sender, EventArgs e)
        {     
            int iRequiredRows = Convert.ToInt32(txtNoOfRows.Text);
            txtOutput.Text = "";

            RDGenTable RDGenSelectedTable = new RDGenTable(cbTableList.Text);
            ColumnsGrid.DataSource = RDGenSelectedTable.TableColumns;
            RDGenSelectedTable.GenerateInsertStatements(iRequiredRows);
            txtOutput.Text += " Execute the contents of  " + cbTableList.Text + ".sql" + " in Query Analyzer/r/n";

        }

    }
}